{% load i18n admin_static admin_urls %}

{% if result_hidden_fields %}
  <div class="hiddenfields">
    {% for item in result_hidden_fields %}{{ item }}{% endfor %}
  </div>
{% endif %}
{% if results %}
  <div class="result-list{% if cl.bulk_edit %} bulk-edit{% endif %}" id="bulk-edit-result">
    {% if cl.bulk_edit %}
      <div id="float_toolbar" class="float_toolbar bulk-edit-fill">
        <a id="fill_all_rows" href="#" title="Fill all rows">
          <i class="fa fa-arrows-v fa-lg" aria-hidden="true"></i>
        </a>
      </div>
    {% endif %}
    <table id="result_list" class="full stripped">
      <thead>
        <tr>
        {% for header in result_headers %}
          <th scope="col" {{ header.class_attrib }}>
            <div class="text">
              {% if header.sortable %}
                <a href="{{ header.url_primary }}">
                  {{ header.text|capfirst }}
                  {% if header.sort_priority > 0 %}
                    <i class="sort-icon fa fa-sort-{% if header.ascending %}asc{% else %}desc{% endif %}" aria-hidden="true"></i>
                  {% endif %}
                </a>
                {% if header.sort_priority > 0 %}
                  <div class="sortoptions">
                    <a class="sortremove" href="{{ header.url_remove }}" title="{% trans "Remove from sorting" %}">
                      <i class="fa fa-times" aria-hidden="true"></i>
                    </a>
                  </div>
                {% endif %}
              {% else %}
                <span>
                  {{ header.text|capfirst }}
                </span>
              {% endif %}
            </div>
          </th>
        {% endfor %}
        </tr>
      </thead>
      <tbody>
        {% for result in results %}
          {% if result.form.non_field_errors %}
              <tr>
                <td olspan="{{ result|length }}">{{ result.form.non_field_errors }}</td>
              </tr>
          {% endif %}
          <tr>{% for item in result %}{{ item }}{% endfor %}</tr>
        {% endfor %}
      </tbody>
    </table>
  </div>
{% else %}
  <div data-alert class="alert-box info">
  {% with cl.any_filters as any_filters %}
    {% url cl.opts|admin_urlname:'add' as add_url %}
    {% trans 'Nothing to display.' %}
    {% if not any_filters %}
      {% blocktrans with cl.opts.verbose_name as name %}
        You can <a href="{{ add_url }}">add first {{ name }}</a>.
      {% endblocktrans %}
    {% endif %}
  {% endwith %}
  </div>
{% endif %}
